<?php
/**
 * @Author: Ron Chen
 * @Date:   2016-12-05 21:56:11
 * @Last Modified by:   Ron Chen
 * @Last Modified time: 2017-10-07 23:09:41
 */

namespace common\services;

use Yii;
use common\models\quyouji\MenuUser;
/**
*  参数获取服务
*/
class MenuUserService
{
	/**
	 * 获取已经上架的菜单项--顶级菜单项目
	 */
	public function getMenuList(){
		$condition = "is_valid=1 AND status=1 AND p_id=0";
		$menu_list = MenuUser::find()->where($condition)->limit(10)->asArray()->all();
		if ($menu_list) {
			return $menu_list;
		}
		return [];
	}

	/**
	 * 获取已经上架的菜单项--二级菜单项目
	 */
	public function getSubMenuList($pid){
		if (!$pid) {
			return [];
		}
		$condition = sprintf("is_valid=1 AND status=1 AND p_id=%s",$pid);
		$menu_list = MenuUser::find()->where($condition)->limit(10)->asArray()->all();
		if ($menu_list) {
			return $menu_list;
		}
		return [];
	}

	
}